package com.dwliu.javaabc;

public class ClassRelative {
	private int testint;
	private String teststr;
	private boolean testbool;
	private long testlong;

	
	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (testbool ? 1231 : 1237);
		result = prime * result + testint;
		result = prime * result + (int) (testlong ^ (testlong >>> 32));
		result = prime * result + ((teststr == null) ? 0 : teststr.hashCode());
		return result;
	}
	
// string 的hashCode
//    public int hashCode() {
//        int h = hash;
//        if (h == 0 && value.length > 0) {
//            char val[] = value;
//
//            for (int i = 0; i < value.length; i++) {
//                h = 31 * h + val[i];
//            }
//            hash = h;
//        }
//        return h;
//    }

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ClassRelative other = (ClassRelative) obj;
		if (testbool != other.testbool)
			return false;
		if (testint != other.testint)
			return false;
		if (testlong != other.testlong)
			return false;
		if (teststr == null) {
			if (other.teststr != null)
				return false;
		} else if (!teststr.equals(other.teststr))
			return false;
		return true;
	}



	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
